home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 050a.dms / 050a.adf / TEXTS / chapter21.txt < prev    next >
Text File  |  1992-02-26  |  5KB  |  96 lines

  1.                      The Absolute Beginners Guide To Amos
  2.                     -------------------------------------
  3.                               Chapter Twenty One
  4.                              -------------------
  5. I am now going to attempt to explain the mysteries of the SHIFT command.
  6. It's another one of those commands that are quite simple in practice but 
  7. difficult to explain in theory so I won't go on about it for too long. 
  8. Example21.Amos contains the following code:
  9.  
  10. HIDE ON
  11. UNPACK 10 TO 0
  12. SHIFT UP 1,1,31,1
  13. WAIT KEY
  14. EDIT
  15.  
  16. What this amazingly small piece of code achieves is an absolutely stunning
  17. scrolling starfield. Please take a look at it now otherwise you will
  18. probably not understand what I am droning on about.
  19.  
  20. Had a look? Good wasn't it? This is how it was done:
  21.  
  22. Stored in bank 10 is a SPACKed 32 colour picture of a black screen with
  23. some white dots put on it. You can see this picture by going into direct
  24. mode (Escape) and typing in UNPACK 10 TO 0. If the stars are still moving
  25. then type in SHIFT OFF.
  26.  
  27. Back to the program. Amos unpacks this screen and displays it then executes
  28. the SHIFT command which I will now do a breakdown of.
  29.  
  30. SHIFT UP delay,firstcolour,lastcolour,flag
  31. ------------------------------------------
  32. What the SHIFT command does is to rotate the colours in the picture,
  33. swapping them around starting with firstcolour and ending with lastcolour
  34. which of course you can change to suit your requirements. The delay is just
  35. like the WAIT command, it is measured in 50ths of a second. Try changing the
  36. value of delay (the first number) to see it's effect. The flag indicates
  37. the type of colour rotation. There are two types the one we are using (the
  38. number 1 on the end) just continues cycling the colours until instructed 
  39. otherwise. If we changed this to a 0 the cycle would only last a short while
  40. as Amos would be instructed not to save and replace the colour after
  41. shifting. The best way to see this is to try it.
  42. The firstcolour is the first colour number you want to be shifted in your
  43. picture and lastcolour is obviously the last. Try changing them also.
  44.  
  45. All Shift operations can be instantly killed with the SHIFT OFF command.
  46.  
  47. The only other SHIFT command is SHIFT DOWN which reverses the direction
  48. of the colour shifting. This would make our example stars fly to the left 
  49. instead of the right.
  50.  
  51. As you are probably bored of the self test quizzes we will now move on to
  52. doing simple programming projects.
  53.  
  54. Remember I told you about the joystick commands in chapter 20? Well why
  55. not try to write a small routine to control the left/right movement of the
  56. stars? My idea of a solution in contained in Example22.Amos.
  57.  
  58. Another interrupt driven command you may find interesting is the FLASH
  59. command. We can select any colour and make that FLASH in any colour sequence
  60. at any speed we want. Load up Example21_1.Amos for a VERY simple example of
  61. the FLASH command. I have purposely made it simple and boring so you can
  62. add experimentation to it. But first let us see how it works.
  63.  
  64. Let us presume you have drawn a BOX on the screen as part of a menu system.
  65. When the user clicks the mouse inside the box you want the box to FLASH to
  66. indicate to the user that the box is now selected. Let us say we drew the 
  67. box using INK 6, like this:
  68.  
  69. INK 6
  70. BOX 100,150 TO 200,250
  71.  
  72. We would set up a mouse zone (as described in an earlier chapter) and test
  73. for a mouse click. If the mouse was clicked and the pointer was inside our
  74. box we could then use FLASH to make the box pulsate, like this:
  75.  
  76. FLASH 6,"(FFF,10)(000,10)"
  77.  
  78. Remember the ANIM command? It is a similar set up. The 6 is the colour we
  79. want to FLASH, this applies to PEN as well as INK so it would work on
  80. ANYTHING on the screen that is in colour 6. 
  81.  
  82. The FFF is the RGB value of the first part of the FLASH sequence. FFF is
  83. white. The 10 that follows is a delay in 50ths of a second just like in the 
  84. SHIFT command. The second part of our FLASH sequence is 000 which is black
  85. also with a 10 50ths delay. So our box will FLASH black and white until we
  86. tell it not to. To do that we use FLASH OFF. And that is all there is to it
  87. really. You can of course change the colour values and delay times to 
  88. anything you want and best of all you can have up to 20 sequences in a
  89. single FLASH command, just keep adding them inside the quotes. Load up the
  90. example program and have a jolly good experimentation session and see what
  91. you can come up with.
  92.  
  93.  
  94.                               End of Chapter 21
  95.                               ^^^^^^^^^^^^^^^^^
  96.